<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <link rel="stylesheet" href="./css/style.css" />
    <title>代跑跑管理端</title>
    <script src="js/axios-0.18.0.js"></script>
    <script src="js/vue.min.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>

<body>
    <div class="container" id="app">
        <div class="login-form">
            <h2>代跑跑管理端</h2>
            <input type="text" v-model="username" placeholder="用户名" />
            <input type="password" v-model="password" placeholder="密码" />
            <button @click="submit">登录</button>
            <div style="color: red">{{error}}</div>
        </div>
    </div>
    <script src="http/request.js"></script>
    <script>
        new Vue({
            el: "#app",
            data() {
                return {
                    username: "",
                    password: "",
                    error: "",
                }
            },
            methods: {
                submit() {
                    axios.post("/admin/login", {
                        "username": this.username,
                        "password": this.password,
                    }).then(response => {
                        if (response.code === 1) {
                            localStorage.setItem('dppToken', response.data)
                            window.location.href = "./index.html"
                        } else {
                            this.error = response.msg
                        }

                    })
                },

            }
        })
    </script>
</body>

</html>